# 错误代码
# def sum_square(n):
#     for i in range(1, n / 2 + 1):
#         for j in range(1, i + 1):
#             for k in range(1, i + 1):
#                 for l in range(1, i + 1):
#                     if n == i * i + j * j + k * k + 1 * 1:
#                         print(n, '=', i, '*', i, '+', j, '*', j, '+', k, '*', k, '+', 1, '*', 1)
#
#
# sum_square(20)

# 正确代码
def sum_squre(n):
    for i in range(1, n // 2 + 1):
        for j in range(1, i + 1): #
            for k in range(1, i + 1):
                for l in range(1, i + 1):
                    if n == i * i + j * j + k * k + l * l:
                        print(n, '=', i, '*', i, '+', j, '*', j, '+',
                              k, '*', k, '+', l, '*', l)


sum_squre(20)